#include<bits/stdc++.h>
using namespace std;
typedef struct{
	int trn[2];
	int len;
	int a[3];
}AD;
AD dui[43],nw;
int lcp[5][5],w[43][43];
void Calc(int x,int y)
{
	memset(lcp,0,sizeof(lcp));
	int n = dui[x].len,m = dui[y].len;
	for(int i = 1;i <= n;i++)
	{
		for(int j = 1;j <= m;j++)
		{
			lcp[i][j] = max(lcp[i - 1][j],lcp[i][j - 1]);
			if(dui[x].a[i - 1] == dui[y].a[j - 1])
				lcp[i][j] = max(lcp[i][j],lcp[i - 1][j - 1] + 1);
		}
	}
	w[x][y] = m - lcp[n][m];
}
int idx = 0;
int tr[4][2] = {{0,1},{1,1},{0,0},{1,0}};
void DFS(int dep)
{
	dui[idx++] = nw;
	if(dep == 3)
		return;
	nw.len = dep + 1;
	for(int i = 1;i <= 3;i++)
	{
		nw.a[dep] = i;
		int x = nw.trn[0],y = nw.trn[1];
		nw.trn[0] = tr[i][nw.trn[0]],nw.trn[1] = tr[i][nw.trn[1]];
		DFS(dep + 1);
		nw.trn[0] = x,nw.trn[1] = y;
	}
	nw.len = dep;
}
int f[1000011][43];
int n;
int a[1000011],b[1000011];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	freopen("hard.in","r",stdin);
	freopen("hard.out","w",stdout);
	nw.trn[0] = 0,nw.trn[1] = 1,DFS(0);
	for(int i = 0;i < idx;i++)
		for(int j = 0;j < idx;j++)
			Calc(i,j);
	memset(f,0x3f,sizeof(f));
	cin >> n;
	for(int i = 1;i <= n;i++)
	{
		char c;
		cin >> c;
		a[i] = (c - '0');
	}
	for(int i = 1;i <= n;i++)
	{
		char c;
		cin >> c;
		b[i] = (c - '0');
	}
	f[0][0] = 0;
	for(int i = 1;i <= n;i++)
		for(int k = 0;k < idx;k++) if(dui[k].trn[a[i]] == b[i])
			for(int j = 0;j < idx;j++)
				f[i][k] = min(f[i][k],f[i - 1][j] + w[j][k]);
	int ans = INT_MAX;
	for(int i = 0;i < idx;i++)
		ans = min(ans,f[n][i]);
	cout << ans;
	return 0;
}